﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace winform_test_7_12
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            // 手动添加下拉框中的内容
            comboBox1.Items.Add("python");
        }

        private void onclickTestButton(object sender, EventArgs e)
        {
            MessageBox.Show("hello world");
            String time = DateTime.Now.ToString("G");
            showTimeBox1.Text = time;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void showTime(object sender, EventArgs e)
        {
            //MessageBox.Show("hello world");
           

        }

        // 自适应窗口：需要重写 OnLayout 方法
        protected override void OnLayout(LayoutEventArgs levent)
        {
            //base.OnLayout(levent);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void showTimeBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            // 获取用户输入了哪个字符
            char ch = e.KeyChar;
            // 判断是否是回车
            if(ch == '\r') {
                String text = showTimeBox1.Text;
                MessageBox.Show("用户输入了： " + text);
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            // 先获取到复选框的 Check 状态
            bool isCheck = checkBox1.Checked;
            if (isCheck) {
                // 让文本框的 passwordChar 属性变为 true
                textBox1.PasswordChar = '\0';
            } else {
                textBox1.PasswordChar = '*';

            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Console.WriteLine("选中了 " + comboBox1.SelectedItem);
        }
    }
}
